
import entity.HttpClient;
import org.junit.Test;

import java.io.IOException;

public class HttpClientDemo {

    @Test
    public void httpDemo() throws IOException {
        // 1.响应地址  用微信的地址“https://api.mch.weixin.qq.com/pay/orderquery”
        String url = "https://api.mch.weixin.qq.com/pay/orderquery";

        //创建HTTPClient对象
        HttpClient httpClient = new HttpClient(url);

        //设置发送数据

        String forword = "<xml><name>王俊冉</name></xml>";

        //设置数据
        httpClient.setXmlParam(forword);

        //http    https
        httpClient.setHttps(true);
        //设置发送方式  带xml的数据都用post
        httpClient.post();

        //获取响应数据

        String content = httpClient.getContent();
        System.out.println(content);
    }
}
